/*
 * 08结构体和指针.c
 *
 *  Created on: 2024年3月15日
 *      Author: sulei_zhang
 */
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>

typedef struct student ss;
struct student {
	char* name;
	int age;
	int* scores;
	char* addr;
};

int main0908(){
	// 通过结构体指针操作堆空间
	ss* p = (ss*)malloc(sizeof(ss)*3);
	for(int i=0; i<3; i++){
		// 也可以p[i].name
		(p+i)->name = (char*)malloc(sizeof(char)*21);
		(p+i)->scores = (int*)malloc(sizeof(int)*3);
		(p+i)->addr = (char*)malloc(sizeof(char)*51);
	}

	for(int i=0; i<3; i++){
		scanf("%s%d%d%d%d%s", p[i].name, &p[i].age, &p[i].scores[0], &p[i].scores[1], &p[i].scores[2], p[i].addr);
	}

	for(int i=0; i<3; i++){
		printf("%s\n", p[i].name);
		printf("%d\n", p[i].age);
		printf("%d\n", p[i].scores[0]);
		printf("%d\n", (p+i) -> scores[1]);
		printf("%d\n", (p+i) -> scores[2]);
		printf("%s\n", (p+i) -> addr);
	}

	for(int i=0; i<3; i++){
		free(p[i].name);
		free(p[i].scores);
		free(p[i].addr);
	}
	free(p);

	return 0;
}
